package spittr.data;

import java.util.Date;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

public class Spittle
{
    private final Long id;

    @NotNull
    @Size(min = 1, max = 140)
    private final String message;

    private final Date time;

    @Min(-180)
    @Max(180)
    private Double latitude;

    @Min(-90)
    @Max(90)
    private Double longitude;

    public Spittle(String message, Date time)
    {
        this(message, time, null, null);
    }

    public Spittle(String message, Date time, Double longitude, Double latitude)
    {
        this.id = null;
        this.message = message;
        this.time = time;
        this.longitude = longitude;
        this.latitude = latitude;
    }

    public Long getId()
    {
        return id;
    }

    public String getMessage()
    {
        return message;
    }

    public Date getTime()
    {
        return time;
    }

    public Double getLatitude()
    {
        return latitude;
    }

    public Double getLongitude()
    {
        return longitude;
    }

    @Override
    public int hashCode()
    {
        return HashCodeBuilder.reflectionHashCode(this, "id", "time");
    }

    @Override
    public boolean equals(Object obj)
    {
        return EqualsBuilder.reflectionEquals(this, obj, "id", "time");
    }

}
